// <copyright file="PackageFolder.cs" company="Bill Fellows">
// Copyright (c) But not really, use it as you see fit. All rights reserved.
// </copyright>
namespace SSISDeploy.Components
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Diagnostics;
    using System.Text.RegularExpressions;

    /// <summary>
    /// A quick and dirty solution to the whole packages and folders things
    /// </summary>
    public class PackageFolder
    {
        /// <summary>
        /// Indicator of whether the current thing is a package
        /// </summary>
        private bool isPackage;

        /// <summary>
        /// Indicator of whether the current thing is a folder
        /// </summary>
        private bool isFolder;

        /// <summary>
        /// The name of the item
        /// </summary>
        private string name;

        /// <summary>
        /// The path where a PackageFolder item lives.
        /// </summary>
        private string path;

        /// <summary>
        /// The version of a package
        /// </summary>
        private string version;

        /// <summary>
        /// The creation date of a package
        /// </summary>
        private string createDate;

        /// <summary>
        /// Gets or sets a value indicating whether it is package type.  Setting this value
        /// as true will unset IsFolder.
        /// </summary>
        public bool IsPackage
        {
            get
            { 
                return this.isPackage; 
            }

            set 
            { 
                this.isPackage = value;
                if (value)
                {
                    this.IsFolder = !value;
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether it is a folder type.  Setting this value
        /// as true will logically unset IsPackage.
        /// </summary>
        public bool IsFolder
        {
            get 
            { 
                return this.isFolder; 
            }

            set 
            { 
                this.isFolder = value;
                if (value)
                {
                    this.isPackage = !value;
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating the item's name
        /// </summary>
        public string Name
        {
            get { return this.name; }
            set { this.name = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating the fully qualified path to the current object.  This is also the parent folder's path
        /// </summary>
        public string Path
        {
            get { return this.path; }
            set { this.path = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating the package's version
        /// </summary>
        public string Version
        {
            get { return this.version; }
            set { this.version = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating the date and time an object was created.  This might be better served as 
        /// a DateTime datatype.
        /// </summary>
        public string CreateDate
        {
            get { return this.createDate; }
            set { this.createDate = value; }
        }

        /// <summary>
        /// Provide a kinder, gentler implementation of the method.
        /// </summary>
        /// <returns>Indicate what type we are dealing with and the name</returns>
        public override string ToString()
        {
            return this.isFolder ? string.Format("Folder:  {0}", this.name) : string.Format("Package:  {0} v{1} {2}", this.name, this.version, this.createDate);
        }
    }
}
